/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.freedom.imarket.controller.json.designer;

import java.util.Hashtable;
import java.util.Map;

/**
 *
 * @author edoardo
 */
public class DataTypeUtil {

    private static Map<String, Xtype> hibernateToXtypeMapper = new Hashtable<String, Xtype>();

    static {
        hibernateToXtypeMapper.put("integer", Xtype.numberfield);
        hibernateToXtypeMapper.put("long", Xtype.numberfield);
        hibernateToXtypeMapper.put("short", Xtype.numberfield);
        hibernateToXtypeMapper.put("character", Xtype.textfield);
        hibernateToXtypeMapper.put("big_decimal", Xtype.numberfield);
        hibernateToXtypeMapper.put("floar", Xtype.numberfield);
        hibernateToXtypeMapper.put("double", Xtype.numberfield);
        hibernateToXtypeMapper.put("boolean", Xtype.radiofield);
        hibernateToXtypeMapper.put("yes_no", Xtype.radiofield);
        hibernateToXtypeMapper.put("true_false", Xtype.radiofield);
        hibernateToXtypeMapper.put("string", Xtype.textfield);
        hibernateToXtypeMapper.put("text", Xtype.textarea);
        hibernateToXtypeMapper.put("date", Xtype.datefield);
        hibernateToXtypeMapper.put("time", Xtype.timefield);
        hibernateToXtypeMapper.put("timestamp", Xtype.timefield);
        hibernateToXtypeMapper.put("calendar", Xtype.datefield);
        hibernateToXtypeMapper.put("calendar_date", Xtype.datefield);
        hibernateToXtypeMapper.put("locale", Xtype.textfield);
        hibernateToXtypeMapper.put("timezone", Xtype.textfield);
        hibernateToXtypeMapper.put("currency", Xtype.textfield);
        hibernateToXtypeMapper.put("clob", Xtype.filefield);
        hibernateToXtypeMapper.put("blob", Xtype.filefield);
        hibernateToXtypeMapper.put("binary", Xtype.filefield);
    }

    public static Xtype getExtTypeFromHibernateType(String fieldType) {

        return hibernateToXtypeMapper.get(fieldType);

    }
}
